import config from './config.js'

export default function install(Vue) {

    Vue.http.interceptors.push({

        request (request) {
            config.auth(request);
            return request;
        },

        response (response) {
            console.log(response);
            if(response.data.code != 10000){
                response.ok = false;
            }

            return response;

            /*// alert("----")
            Message.hide()

            // 拦截session过期
            if (response.data.code === 50000) {
                setTimeout(()=> {
                    router_proto.go({name: 'login'})
                })
            }

            if ((response.data.code === 30000 || response.data.code === 40000 || response.data.code === 20000 || response.data.code === 99999) && response.request.url != './session/login') {
                Message.show('error', response.data.message, 1)
            }

            if (response.data.code !== 10000) {
                response.ok = false
            }*/
        }
    })
}




